package com.frogs.ucenter.dao.ibatis;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Repository;

import com.frogs.framework.base.dao.ibatis.BaseDaoIbatis;
import com.frogs.framework.util.PageList;
import com.frogs.ucenter.dao.UserAttentionInfoDao;
import com.frogs.ucenter.entity.UserAttentionInfo;
import com.frogs.ucenter.entity.ext.UserAttentionInfoExt;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository("userAttentionInfoDao")
public class UserAttentionInfoDaoImpl extends BaseDaoIbatis<UserAttentionInfo> implements UserAttentionInfoDao {

    public UserAttentionInfoDaoImpl() {
        super();
        setNameSpace( "user_attention_info" );
    }

    @Required
    @Resource
    public void setSqlMapClientAutowired(SqlMapClient sqlMapClient) {
        super.setSqlMapClient( sqlMapClient );
    }
    
    @Override
	public PageList<UserAttentionInfoExt> selectByMapForFans(Map<String, Object> params, int pageNo, int pageSize) {
		return queryforPageList(getNameSpace() + ".selectByMapForFans", params, pageNo, pageSize);
	}
    
	@Override
	public PageList<UserAttentionInfoExt> selectByMapForAttention(Map<String, Object> params, int pageNo, int pageSize) {
		return queryforPageList(getNameSpace() + ".selectByMapForAttention", params, pageNo, pageSize);
	}
	
	@Override
	public Map<String, Object> statisticById(Map<String, Object> params) throws Exception {
		List result = getSqlMapClientTemplate().queryForList(getNameSpace() + ".statisticById", params);
		
		if(result.size() > 0)
			return (Map<String,Object>)result.get(0);
		
		return new HashMap<String,Object>(); 
	}
}